﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Net.NetworkInformation;

namespace CS322_V7
{
    public partial class FormNetworkInterfaces : Form
    {
        public FormNetworkInterfaces()
        {
            InitializeComponent();
        }

        private void Form1_Load(object sender, EventArgs e)
        {

            TreeNodeCollection treeNodes = tvwNetwork.Nodes;

            // Mrezni interfejsi se proveravaju samo ako postoji mreža
            if (NetworkInterface.GetIsNetworkAvailable())
            {
                // Niz NetworkInterface[] predstavlja niz objekata NetworkInterface koji sadrze informacije o mreznim interfejsima lokalne masine.
                NetworkInterface[] interfaces =
                NetworkInterface.GetAllNetworkInterfaces();


                // prolazak kroz mrezne interfejse i popunjavanje objekta tvwNetwork koji se nalazi na formi.
                foreach (NetworkInterface ni in interfaces)
                {
                    
                    TreeNode newTreeNode = treeNodes.Add(ni.Name);
                    newTreeNode.Nodes.Add(ni.Description);
                    newTreeNode.Nodes.Add(ni.Id);
                    newTreeNode.Nodes.Add(ni.GetPhysicalAddress().ToString());
                    
                }

            }
            else
            {
                MessageBox.Show("Ni jedan mrezni interfejs ne postoji.");
            }
            tvwNetwork.ExpandAll();

           
        }

        private void pnlNetwork_Paint(object sender, PaintEventArgs e)
        {

        }

        


    }
}
